package com.serverlite.system.user.service;

import java.util.HashMap;
import java.util.Map;

import com.serverlite.framework.dao.core.Dao;
import com.serverlite.system.config.AppConfig;

public class UserService {
    
    public static Map<String,Object> login(String username, String password){
        Map<String,Object> o;
        //判断是不是超级管理员
        if(isAdmin(username,password)){
            o = new HashMap<String,Object>();
            o.put("username", username);
            o.put("password", password);
        } else {
            o = Dao.queryOne("select * from system_user where username=? and password=?", username, password);
        }
        return o;
    }
    
    /**
     * 判断是不是超级管理员
     */
    public static boolean isAdmin(String username, String password){
        if(AppConfig.ADMIN_NAME.equals(username) && AppConfig.ADMIN_PASSWORD.equals(password)){
            return true;
        } else {
            return false;
        }
    }
}
